<?php
class BaseAction extends Action {
	
	  protected $option;
		function _initialize() {
		   // 用户权限检查
		   if(!(MODULE_NAME == 'Public')){
				 if(empty($_SESSION['account'])){
					  $this->redirect("Public/login");
			 	 }
		   }
			//参数转义
      new_addslashes($_POST);
      new_addslashes($_GET);
      $_POST = $this->__filterLabel( $_POST );
      //parent::_initialize();   
      
      //网站参数
      
      $this->option = $this->__getOption();
      $this->assign("option",$this->option);   
	  }
	  
	  private function __filterLabel( $data ){
        foreach( $data as &$value ){
            if( is_array($value) ){
                foreach( $value as &$v ){
                    $v = showHtml( $v );
                }
            }else{
                $value = showHtml( $value );
            }
        }
        return $data;

    }
    
    private function __getOption(){
    	if(!S("site_option")){
    	 $ops = M("Option")->findAll();
    	 foreach($ops as $op){
    	 	 $temp[$op['name']] = $op['value'];
    	 }
    	 S("site_option",$temp);
    	}
    	
    	return S("site_option");
    }
    
    
}
?>